setReorderingAllowed
Sets whether or not to allow optimizing operations within and across transactions. This will remove redundant operations, eliminating operations that cancel. For example, if two transactions are executed together, one that adds a fragment A and the next replaces it with fragment B, the operations will cancel and only fragment B will be added. That means that fragment A may not go through the creation/destruction lifecycle.
The side effect of removing redundant operations is that fragments may have state changes out of the expected order. For example, one transaction adds fragment A, a second adds fragment B, then a third removes fragment A. Without removing the redundant operations, fragment B could expect that while it is being created, fragment A will also exist because fragment A will be removed after fragment B was added. With removing redundant operations, fragment B cannot expect fragment A to exist when it has been created because fragment A's add/remove will be optimized out.
It can also reorder the state changes of Fragments to allow for better Transitions. Added Fragments may have onCreate called before replaced Fragments have onDestroy called.
postponeEnterTransition requires setReorderingAllowed(true)
.
The default is false
.
Parameters
true
to enable optimizing out redundant operations or false
to disable optimizing out redundant operations on this transaction.